<?php
namespace app\admin\validate;
use think\Validate;

class User extends Validate
{
    // 定义验证规则

    protected $rule = [
        'uname' => 'require|unique:user',
        'password' => 'require',
        'repassword' => 'require|confirm:password',
        'email' => 'require|email',
    ];


    protected $scene =[
        'add' =>['uname','pwd','email'],
        'edit' =>['uname','pwd']
    ];

    //定义错误信息

    protected $message = [
        'newpassword.requireWith' => '确认密码不能为空',
        'newpassword.confirm'     => '两个新密码不一致',
    ];

    public function sceneEdit()
    {
        return $this->only(['name','password'])->remove('uname','unique:user');
    }


}